package com.zzh.takeoutapp.activity;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.zzh.takeoutapp.R;
import com.zzh.takeoutapp.adapter.TagAdapter;
import com.zzh.takeoutapp.base.BaseActivity;
import com.zzh.takeoutapp.utils.DividerGridItemDecoration;
import com.zzh.takeoutapp.view.folw.FlowTagLayout;
import com.zzh.takeoutapp.view.folw.OnTagClickListener;
import com.zzh.takeoutapp.view.folw.OnTagSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/7/25.
 */

public class SearchActivity extends BaseActivity implements OnTagSelectListener, OnTagClickListener {

    @Bind(R.id.size_flow_layout)
    FlowTagLayout mSizeFlowLayout;
    @Bind(R.id.history_flow_layout)
    FlowTagLayout mHistoryFlowLayout;
    @Bind(R.id.recyclerView)
    ListView mListView;
    @Bind(R.id.tv_search_cancel)
    TextView tvSearchCancel;
    private TagAdapter<String> mSizeTagAdapter;
    private List<String> dataSource = new ArrayList<>();

    @Override
    public void setContent() {
        setContentView(R.layout.activity_search);
        ButterKnife.bind(this);
    }

    @Override
    public void initComponent() {
        dataSource.add("热门");
        dataSource.add("披萨");
        dataSource.add("鸡肉卷");
        mSizeTagAdapter = new TagAdapter<>(this);
        mSizeTagAdapter.onlyAddAll(dataSource);
        mSizeFlowLayout.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_SINGLE);
        mSizeFlowLayout.setAdapter(mSizeTagAdapter);
        mHistoryFlowLayout.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_SINGLE);
        mHistoryFlowLayout.setAdapter(mSizeTagAdapter);
        mSizeTagAdapter.notifyDataSetChanged();
        List stringList = new ArrayList<>();
        stringList.add("综合排序");
        stringList.add("速度最快");
        stringList.add("评分最高");
        stringList.add("起送价最低");
        stringList.add("配送费最低");
        stringList.add("人均高到低");
        stringList.add("人均低到高");
        final ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, stringList);
        mListView.setAdapter(arrayAdapter);
        arrayAdapter.notifyDataSetChanged();

    }

    @OnClick({R.id.tv_search_cancel})
    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.tv_search_cancel:
                this.finish();
                break;
        }

    }

    @Override
    public void setListener() {
        mSizeFlowLayout.setOnTagSelectListener(this);
        mHistoryFlowLayout.setOnTagSelectListener(this);
        mHistoryFlowLayout.setOnTagClickListener(this);
    }

    @Override
    public void onAfterInit() {

    }

    @Override
    public void onItemSelect(FlowTagLayout parent, List<Integer> selectedList) {

    }

    @Override
    public void onItemClick(FlowTagLayout parent, View view, int position) {

    }
}
